<style type="text/css">

</style>
<div class="layui-row">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-inline">
                <input type="text" name="username" required lay-verify="required" placeholder="请输入用户名"
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码框</label>
            <div class="layui-input-inline">
                <input type="password" name="password" required lay-verify="required" placeholder="请输入密码"
                       autocomplete="off"
                       class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux"><span style="user-select: none;">一段内容（无法选中）</span></div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">业务角色</label>
            <div class="layui-input-block">
                <input type="radio" name="roleSign" value="1" title="招标人/采购人">
                <input type="radio" name="roleSign" value="2" title="投标人/供应商">
                <input type="radio" name="roleSign" value="3" title="代理机构" checked>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<div class="layui-row">
    <button class="layui-btn" type="button" lay-active="test">测试</button>
    <button id="uploadTest" class="layui-btn" type="button">文件上传</button>
</div>
<!---->
<script type="text/javascript">
    layui.use(['layer', 'laytpl', 'util', 'form'], function () {
        let layer = layui.layer;
        let laytpl = layui.laytpl;
        let util = layui.util;
        let form = layui.form;
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#uploadTest', //绑定元素
            accept: 'file',
            field: 'files',
            // url: 'http://local.fzznkj.com:8511/own/file/upload/server', //上传接口
            // url: 'http://127.0.0.1:8090/own/file/upload/server', //上传接口
            url: 'http://127.0.0.1:8180/file/upload/local', //上传接口
            done: function (res) {
                //上传完毕回调
                console.log(res, '1');
            },
            error: function (err) {
                //请求异常回调
                console.log(err, '2');
            }
        });

        let active = {
            login: function (data) {
                let config = {
                    type: "post",
                    // url: 'http://127.0.0.1:8090/own/manage/enterprise/auditEnterprise',
                    url: 'http://127.0.0.1:33000/api/oauth/Login',
                    // url: 'http://127.0.0.1:33000/api/oauth/ImageCode/4/' + new Date().getTime(),
                    // url: 'http://127.0.0.1:33000/RSA/publicKey',
                    // url: 'http://127.0.0.1:33000/login/test',
                    // url: 'http://127.0.0.1:33000/api/oauth/test/test',

                    // contentType: "application/json",
                    // data: JSON.stringify(data),

                    data: data,

                    dataType: 'json',
                    success: (res) => {
                        console.log(res)
                    }
                };
                layui.jquery.ajax(config);
            },
            test() {
                // let testUrl = "http://127.0.0.1:8080/hbcenter/v2.0/enum/dicts/all";
                let testUrl = "http://127.0.0.1:8083/enum/dicts/all";
                request.bodyAjax(testUrl, {
                    actionId: 1,
                    pageLimit: 10
                }, function (res) {
                    console.log(res)
                });

/*                $.ajax({
                    url: 'http://127.0.0.1:8080/hbcenter/v2.0/dicCode/listDicCodes',
                    type: 'get',
                    data: JSON.stringify({
                        "typeId": 123
                    }),
                    processData: false,
                    contentType: "application/json",
                    dataType: 'json',
                    headers: {'Content-Type': 'application/json'},
                    // beforeSend: function (XMLHttpRequest) {
                    //     XMLHttpRequest.setRequestHeader("showLoading", "false");
                    // },
                    success: function (res) {
                        console.log(res);
                    }
                });*/
                /*                var data = JSON.stringify({
                                    "typeCode": "COMPANY_NATURE"
                                });

                                var xhr = new XMLHttpRequest();

                                xhr.addEventListener("readystatechange", function () {
                                    if (this.readyState === 4) {
                                        console.log(this.responseText);
                                    }
                                });

                                xhr.open("GET", "http://127.0.0.1:8070/data/listDicCode");

                                xhr.withCredentials = false;
                                xhr.setRequestHeader("Content-Type", "application/json");
                                xhr.setRequestHeader("Accept", "*!/!*");
                                xhr.setRequestHeader("Cache-Control", "no-cache");

                                xhr.send(data);*/
            }
        };

        // layui的btn单独添加点击事件
        util.event('lay-active', active);


        form.on('submit(formDemo)', function (data) {
            active.login(data.field);
            return false;
        });

        form.render();

        // const a = 1;
        // a = 2;

        let aa = 1;
        aa = 2;

        let arrs = [1];
        arrs[1] = 2;
        console.log(arrs);

    });
</script>
